using System.IO;
using UnityEditor;
using UnityEngine;

namespace IQIGame.Onigao.Game.Editors
{
    public static class ConfigurableFSMMenu
    {
        [MenuItem("GameEditor/StateMachine/导出全部")]
        private static void ExportAllFSMAsync()
        {
            string assetDir = Application.dataPath;
            string rootDir = assetDir.Substring(0, assetDir.Length - "Assets".Length);
            string fsmConfigDir = rootDir + "StateMachine/source";
            string[] files = Directory.GetFiles(fsmConfigDir, "*.graphml", SearchOption.AllDirectories);
            foreach (var file in files)
            {
                CfgFSMExporter exporter = CfgFSMExporter.Create(fsmConfigDir, file);
                exporter?.ExportData();
            }
            Debug.Log("导出完毕");
        }

        [MenuItem("GameEditor/StateMachine/生成代码")]
        private static void ExportCode()
        {
            CFSMGeneratorWindow.ShowWindow();
        }
    }
}
